package com.foucus.myfouces.Resource.Util;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;

import static android.R.attr.value;

/**
 * SharedPreferences工具 (缓存一些常用数据)
 *
 * @author Administrator
 */
public class SharedPreferencesUtil {

    private static final String SECURITY_KEY = "SECURITY_KEY";
    public static final String FILENAME = "SharedPreferences";
    public static final String FIRSTRUN = "firstrun";

    public static final String JINGDU = "jingdu"; //经度
    public static final String WEIDU = "weidu";//纬度
    public static final String MOBILE = "monile";  //用户手机号码
    public static final String PASSWORD = "password";//用户的密码
    public static final String TOKEN = "token";//登录返回的token
    public static final String MEMBERID = "memberid";//用户id
    //第三方登录
    public static final String OPENID = "openid";//openid
    public static final String TYPE = "type";//type
    public static final String NICKNAME = "nickname";//nickname
    public static final String GENDER = "gender";//gender
    public static final String THUMB = "thumb";//thumb

    //1 => '启动页',//2 => '拍摄页',//3 => '导入编辑',//4 => '拍摄',//5 => '存稿',//6 => '首页',//7 => '首页(点击)',//8 => '关注',//9 => '关注(点击)',
    //10 => '拍摄',//11 => '拍摄(点击)',//12 => '技巧',//13 => '技巧(点击)',//14 => '我的',//15 => '我的(点击)',//16 => '搜索',//17 => '好友',
    //18 => '设置',//19 => '我的消息',//20 => '我的图集',//21 => '关注好友',//22 => '传输列表',//23 => '草稿箱',

    public static final String STARTPAGE = "start_page";//启动页
    public static final String PHOTOGRAPHYPAGE = "photography_page";//拍摄页
    public static final String PHOTOGRAPHYPAGEPATH = "photography_page_path";//拍摄页路径
    public static final String INPUTEDIT = "input_edit";//导入编辑
    public static final String PHOTOGRAPHY1 = "photography1";//拍摄
    public static final String SAVEDRAFT = "save_draft";//存稿
    public static final String HOMEPAGE = "homepage";//首页
    public static final String HOMEPAGECLICK = "homepage_click";//首页（点击）
    public static final String ATTENTION = "attention";//关注
    public static final String ATTENTIOMCLICK = "attention_click";//关注（点击）
    public static final String PHOTOGRAPHY = "photography";//拍摄
    public static final String PHOTOGRAPHYCLICK = "photography_click";//拍摄(点击)
    public static final String SKILL = "skill";//技巧
    public static final String SKILLCLICK = "skill_click";//技巧（点击）
    public static final String MY = "my";//我的
    public static final String MYCLICK = "my_click";//我的（点击）
    public static final String SEARCH = "search";//搜索
    public static final String FRIEND = "friend";//好友
    public static final String SETTING = "setting";//设置
    public static final String MYMESSAGE = "my_message";//我的消息
    public static final String MYPHOTO = "my_photo";//我的图集
    public static final String ATTENTIONFRIEND = "attention_friend";//关注好友
    public static final String TRANSMITLIST = "transmit_list";//传输列表
    public static final String DRAFT = "draft";//草稿箱

    public static final String BannerResponse = "bannerResponse";//首页广告栏
    public static final String SquareResponse = "SquareResponse";//广场数据（今日精选、热门夯作、电影预告）
    public static final String LoginResponse = "LoginResponse";//登录返回的数据
    public static final String Top3Response = "Top3Response";//Top3的数据
    public static final String Top5PartnerResponse = "Top5PartnerResponse";//Top5明星搭档的数据
    public static final String PhotoResponse = "PhotoResponse";//图集的数据
    public static final String ReplyResponse = "ReplyResponse";//留言的数据
    public static final String MyWorkResponse = "MyWorkResponse";//作品的数据


    public static final String CONTRACTSEARCHME = "contract_search_me";//通过通讯录可以搜索到我（0为不可以，1位可以）

    public static final String VIDEOPLAYTYPE = "video_play_type";//视频播放类型（禁止自动播放：ban_auto_play  3G/4G和Wi-Fi:all  仅Wi-Fi:wifi）

    public static final String SID = "sid";


    public static final String INTEGRAL = "integral";


    //推送数
    public static final String PUSH = "PUSH";

    //会员消息
    public static final String VIPMESSAGE = "VIPMESSAGE";

    //系统消息
    public static final String SYSTEMMESSAGE = "SYSTEMMESSAGE";

    //字體
    public static final String LANGUAGE = "LANGUAGE";

    /**
     * 是否提示过系统更新信�?
     */
    public static final String VERSION = "version";

    /**
     * 更新信息
     */
    public static final String UPDATEMSG = "updatemsg";

    /**
     * wifi加载图片
     */
    public static final String WIFILOAD = "wifiload";

    /**
     * 系统消息
     */
    public static final String SYSTEMMSG = "systemmsg";

    /**
     * 圈子消息
     */
    public static final String CIRCLEMSG = "circlemsg";

    /**
     * 好友消息
     */
    public static final String FRIENDMSG = "friendmsg";

    /**
     * 声音
     */
    public static final String VOICE = "voice";

    /**
     * 震动
     */
    public static final String VIBRATE = "vibrate";

    /**
     * 密码
     */
    public static final String CITYCODE = "citycode";


    /**
     * 城市编码
     */
    public static final String CITYNAME = "cityname";

    /**
     * 城市编码
     */

    public static final String COOKIE = "cookie";

    private static SharedPreferencesUtil instance;
    private SharedPreferences settings;

    private Editor editor;

    private SharedPreferencesUtil(Context context) {
        settings = context.getSharedPreferences(FILENAME, Context.MODE_PRIVATE);
        editor = settings.edit();
    }

    /**
     * 配置�?要区分用户名存储�?
     *
     * @param context
     * @return
     */
    public static SharedPreferencesUtil getInstance(Context context) {
        if (instance == null) {
            instance = new SharedPreferencesUtil(context);
        }
        return instance;
    }

    public SharedPreferences getSharedPreferences() {
        return settings;
    }

    public Editor getEditor() {
        return editor;
    }

    public void setJingdu(String jingdu) {
        editor.putString(JINGDU, jingdu);
        editor.commit();
    }

    public String getJingdu() {
        return settings.getString(JINGDU, "0");
    }

    public void setWeidu(String weidu) {
        editor.putString(WEIDU, weidu);
        editor.commit();
    }

    public String getWeidu() {
        return settings.getString(WEIDU, "0");
    }

    public String getMobile() {
        return settings.getString(MOBILE, "");
    }

    public void setMobile(String mobile) {
        editor.putString(MOBILE, mobile);
        editor.commit();
    }

    public String getToken() {
        return settings.getString(TOKEN, "");
    }

    public void setToken(String token) {
        editor.putString(TOKEN, token);
        editor.commit();
    }

    public String getMemberid() {
        return settings.getString(MEMBERID, "null");
    }

    public void setMemberid(String memberid) {
        editor.putString(MEMBERID, memberid);
        editor.commit();
    }

    public String getOpenid() {
        return settings.getString(OPENID, "");
    }

    public void setOpenid(String openid) {
        editor.putString(OPENID, openid);
        editor.commit();
    }

    public String getType() {
        return settings.getString(TYPE, "");
    }

    public void setType(String type) {
        editor.putString(TYPE, type);
        editor.commit();
    }

    public String getNickname() {
        return settings.getString(NICKNAME, "");
    }

    public void setNickname(String nickname) {
        editor.putString(NICKNAME, nickname);
        editor.commit();
    }

    public String getGender() {
        return settings.getString(GENDER, "");
    }

    public void setGender(String gender) {
        editor.putString(GENDER, gender);
        editor.commit();
    }

    public String getThumb() {
        return settings.getString(THUMB, "");
    }

    public void setThumb(String thumb) {
        editor.putString(THUMB, thumb);
        editor.commit();
    }


    public String getStartpage() {
        return settings.getString(STARTPAGE, "");
    }

    public void setStartpage(String thumb) {
        editor.putString(STARTPAGE, thumb);
        editor.commit();
    }

    public String getPhotographypage() {
        return settings.getString(PHOTOGRAPHYPAGE, "");
    }

    public void setPhotographypage(String thumb) {
        editor.putString(PHOTOGRAPHYPAGE, thumb);
        editor.commit();
    }

    public String getPhotographypagepath() {
        return settings.getString(PHOTOGRAPHYPAGEPATH, "");
    }

    public void setPhotographypagepath(String thumb) {
        editor.putString(PHOTOGRAPHYPAGEPATH, thumb);
        editor.commit();
    }

    public String getInputedit() {
        return settings.getString(INPUTEDIT, "");
    }

    public void setInputedit(String thumb) {
        editor.putString(INPUTEDIT, thumb);
        editor.commit();
    }

    public String getPhotography1() {
        return settings.getString(PHOTOGRAPHY1, "");
    }

    public void setPhotography1(String thumb) {
        editor.putString(PHOTOGRAPHY1, thumb);
        editor.commit();
    }

    public String getSavedraft() {
        return settings.getString(SAVEDRAFT, "");
    }

    public void setSavedraft(String thumb) {
        editor.putString(SAVEDRAFT, thumb);
        editor.commit();
    }

    public String getHomepage() {
        return settings.getString(HOMEPAGE, "");
    }

    public void setHomepage(String thumb) {
        editor.putString(HOMEPAGE, thumb);
        editor.commit();
    }


    public String getHomepageclick() {
        return settings.getString(HOMEPAGECLICK, "");
    }

    public void setHomepageclick(String thumb) {
        editor.putString(HOMEPAGECLICK, thumb);
        editor.commit();
    }

    public String getAttention() {
        return settings.getString(ATTENTION, "");
    }

    public void setAttention(String thumb) {
        editor.putString(ATTENTION, thumb);
        editor.commit();
    }

    public String getAttentiomclick() {
        return settings.getString(ATTENTIOMCLICK, "");
    }

    public void setAttentiomclick(String thumb) {
        editor.putString(ATTENTIOMCLICK, thumb);
        editor.commit();
    }

    public String getPhotography() {
        return settings.getString(PHOTOGRAPHY, "");
    }

    public void setPhotography(String thumb) {
        editor.putString(PHOTOGRAPHY, thumb);
        editor.commit();
    }

    public String getPhotographyclick() {
        return settings.getString(PHOTOGRAPHYCLICK, "");
    }

    public void setPhotographyclick(String thumb) {
        editor.putString(PHOTOGRAPHYCLICK, thumb);
        editor.commit();
    }

    public String getSkill() {
        return settings.getString(SKILL, "");
    }

    public void setSkill(String thumb) {
        editor.putString(SKILL, thumb);
        editor.commit();
    }

    public String getSkillclick() {
        return settings.getString(SKILLCLICK, "");
    }

    public void setSkillclick(String thumb) {
        editor.putString(SKILLCLICK, thumb);
        editor.commit();
    }

    public String getMy() {
        return settings.getString(MY, "");
    }

    public void setMy(String thumb) {
        editor.putString(MY, thumb);
        editor.commit();
    }

    public String getMyclick() {
        return settings.getString(MYCLICK, "");
    }

    public void setMyclick(String thumb) {
        editor.putString(MYCLICK, thumb);
        editor.commit();
    }

    public String getSearch() {
        return settings.getString(SEARCH, "");
    }

    public void setSearch(String thumb) {
        editor.putString(SEARCH, thumb);
        editor.commit();
    }

    public String getFriend() {
        return settings.getString(FRIEND, "");
    }

    public void setFriend(String thumb) {
        editor.putString(FRIEND, thumb);
        editor.commit();
    }

    public String getSetting() {
        return settings.getString(SETTING, "");
    }

    public void setSetting(String thumb) {
        editor.putString(SETTING, Rsa.encryptByPublic(String.valueOf(value)));
        editor.commit();
    }


    public String getMymessage() {
        return settings.getString(MYMESSAGE, "");
    }

    public void setMymessage(String thumb) {
        editor.putString(MYMESSAGE, thumb);
        editor.commit();
    }

    public String getMyphoto() {
        return settings.getString(MYPHOTO, "");
    }

    public void setMyphoto(String thumb) {
        editor.putString(MYPHOTO, thumb);
        editor.commit();
    }

    public String getAttentionfriend() {
        return settings.getString(ATTENTIONFRIEND, "");
    }

    public void setAttentionfriend(String thumb) {
        editor.putString(ATTENTIONFRIEND, thumb);
        editor.commit();
    }

    public String getTransmitlist() {
        return settings.getString(TRANSMITLIST, "");
    }

    public void setTransmitlist(String thumb) {
        editor.putString(TRANSMITLIST, thumb);
        editor.commit();
    }

    public String getDraft() {
        return settings.getString(DRAFT, "");
    }

    public void setDraft(String thumb) {
        editor.putString(DRAFT, thumb);
        editor.commit();
    }

    public String getBannerResponse() {
        return settings.getString(BannerResponse, "");
    }

    public void setBannerResponse(String bannerResponse) {
        editor.putString(BannerResponse, bannerResponse);
        editor.commit();
    }

    public String getSquareResponse() {
        return settings.getString(SquareResponse, "");
    }

    public void setSquareResponse(String squareResponse) {
        editor.putString(SquareResponse, squareResponse);
        editor.commit();
    }

    public String getLoginResponse() {
        return settings.getString(LoginResponse, "");
    }

    public void setLoginResponse(String loginResponse) {
        editor.putString(LoginResponse, loginResponse);
        editor.commit();
    }

    public String getTop3Response() {
        return settings.getString(Top3Response, "");
    }

    public void setTop3Response(String top3Response) {
        editor.putString(Top3Response, top3Response);
        editor.commit();
    }

    public String getTop5PartnerResponse() {
        return settings.getString(Top5PartnerResponse, "");
    }

    public void setTop5PartnerResponse(String top5PartnerResponse) {
        editor.putString(Top5PartnerResponse, top5PartnerResponse);
        editor.commit();
    }

    public String getPhotoResponse() {
        return settings.getString(PhotoResponse, "");
    }

    public void setPhotoResponse(String photoResponse) {
        editor.putString(PhotoResponse, photoResponse);
        editor.commit();
    }

    public String getReplyResponse() {
        return settings.getString(ReplyResponse, "");
    }

    public void setReplyResponse(String replyResponse) {
        editor.putString(ReplyResponse, replyResponse);
        editor.commit();
    }

    public String getMyWorkResponse() {
        return settings.getString(MyWorkResponse, "");
    }

    public void setMyWorkResponse(String myWorkResponse) {
        editor.putString(MyWorkResponse, myWorkResponse);
        editor.commit();
    }


    public String getContractsearchme() {
        return settings.getString(CONTRACTSEARCHME, "0");
    }

    public void setContractsearchme(String thumb) {
        editor.putString(CONTRACTSEARCHME, thumb);
        editor.commit();
    }

    public String getVideoplaytype() {
        return settings.getString(VIDEOPLAYTYPE, "wifi");
    }

    public void setVideoplaytype(String thumb) {
        editor.putString(VIDEOPLAYTYPE, thumb);
        editor.commit();
    }


    /**
     * 清空�?有数�?
     */
    public void clearAllData() {
        editor.clear();
        editor.commit();
    }

    public String getCitycode() {
        return settings.getString(CITYCODE, "");// 厦门编号16278
    }

    public void setCitycode(String citycode) {
        editor.putString(CITYCODE, citycode);
        editor.commit();
    }

    public String getCityname() {
        return settings.getString(CITYNAME, "");
    }

    public void setCityname(String cityname) {
        editor.putString(CITYNAME, cityname);
        editor.commit();
    }


    public String getIntegral() {
        return settings.getString(INTEGRAL, "");
    }

    public void setIntegral(String ub) {
        editor.putString(INTEGRAL, ub);
        editor.commit();
    }

    public String getSid() {
        return settings.getString(SID, "");
    }

    public void setSid(String sid) {
        editor.putString(SID, sid);
        editor.commit();
    }

    public int getPush() {
        return settings.getInt(PUSH, 0);
    }

    public void setPush(int num) {
        editor.putInt(PUSH, num);
        editor.commit();
    }

    public int getVipMessage() {
        return settings.getInt(VIPMESSAGE, 0);
    }

    public void setVipMessage(int num) {
        editor.putInt(VIPMESSAGE, num);
        editor.commit();
    }

    public int getSystemMessage() {
        return settings.getInt(SYSTEMMESSAGE, 0);
    }

    public void setSystemMessage(int num) {
        editor.putInt(SYSTEMMESSAGE, num);
        editor.commit();
    }

    public void setLanguage(String language) {
        editor.putString(LANGUAGE, language);
        editor.commit();
    }

    public String getLanguage() {
        return settings.getString(LANGUAGE, "0");
    }

    public int getFirstRun() {
        return settings.getInt(FIRSTRUN, 0);
    }

    public void setFirstRun(int num) {
        editor.putInt(FIRSTRUN, num);
        editor.commit();
    }

    public String getPassword() {
        return settings.getString(PASSWORD, "");
    }

    public void setPassword(String password) {
        editor.putString(PASSWORD, password);
        editor.commit();
    }

    public String getVersion() {
        return settings.getString(VERSION, "1.0");
    }

    public void setVersion(String version) {
        editor.putString(VERSION, version);
        editor.commit();
    }

    public String getUpdateMsg() {
        return settings.getString(UPDATEMSG, "");
    }

    public void setUpdateMsg(String updateMsg) {
        editor.putString(UPDATEMSG, updateMsg);
        editor.commit();
    }

    public Boolean getWifiLoad() {
        return settings.getBoolean(WIFILOAD, true);
    }

    public void setWifiLoad(Boolean updateMsg) {
        editor.putBoolean(WIFILOAD, updateMsg);
        editor.commit();
    }

    public Boolean getSystemMsg() {
        return settings.getBoolean(SYSTEMMSG, true);
    }

    public void setSystemMsg(Boolean systemmsg) {
        editor.putBoolean(SYSTEMMSG, systemmsg);
        editor.commit();
    }

    public Boolean getCircleMsg() {
        return settings.getBoolean(CIRCLEMSG, true);
    }

    public void setCircleMsg(Boolean circlemsg) {
        editor.putBoolean(CIRCLEMSG, circlemsg);
        editor.commit();
    }

    public Boolean getFriendMsg() {
        return settings.getBoolean(FRIENDMSG, true);
    }

    public void setFriendMsg(Boolean friendmsg) {
        editor.putBoolean(FRIENDMSG, friendmsg);
        editor.commit();
    }

    public Boolean getVoice() {
        return settings.getBoolean(VOICE, true);
    }

    public void setVoice(Boolean voice) {
        editor.putBoolean(VOICE, voice);
        editor.commit();
    }

    public Boolean getVibrate() {
        return settings.getBoolean(VIBRATE, true);
    }

    public void setVibrate(Boolean vibrate) {
        editor.putBoolean(VIBRATE, vibrate);
        editor.commit();
    }

    public String getCookie() {
        return settings.getString(COOKIE, "");
    }

    public void setCookie(String cookie) {
        editor.putString(COOKIE, cookie);
        editor.commit();
    }


}
